home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / octa209s.zip / octave-2.09 / src / ov-base.h < prev    next >
C/C++ Source or Header  |  1996-11-11  |  5KB  |  198 lines

  1. /*
  2.  
  3. Copyright (C) 1996 John W. Eaton
  4.  
  5. This file is part of Octave.
  6.  
  7. Octave is free software; you can redistribute it and/or modify it
  8. under the terms of the GNU General Public License as published by the
  9. Free Software Foundation; either version 2, or (at your option) any
  10. later version.
  11.  
  12. Octave is distributed in the hope that it will be useful, but WITHOUT
  13. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14. FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  15. for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with Octave; see the file COPYING.  If not, write to the Free
  19. Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  20.  
  21. */
  22.  
  23. #if !defined (octave_base_value_h)
  24. #define octave_base_value_h 1
  25.  
  26. #if defined (__GNUG__)
  27. #pragma interface
  28. #endif
  29.  
  30. #include <cstdlib>
  31.  
  32. #include <string>
  33.  
  34. class ostream;
  35.  
  36. #include "mx-base.h"
  37. #include "str-vec.h"
  38.  
  39. #include "error.h"
  40. #include "ov.h"
  41. #include "ov-typeinfo.h"
  42.  
  43. class Octave_map;
  44. class octave_value_list;
  45.  
  46. class tree_walker;
  47.  
  48. // A base value type, so that derived types only have to redefine what
  49. // they need (if they are derived from octave_base_value instead of
  50. // octave_value).
  51.  
  52. class
  53. octave_base_value : public octave_value
  54. {
  55. public:
  56.  
  57.   octave_base_value (void)
  58.     : octave_value (octave_xvalue ()) { }
  59.  
  60.   octave_base_value (const octave_base_value&)
  61.     : octave_value (octave_xvalue ()) { }
  62.  
  63.   ~octave_base_value (void) { }
  64.  
  65.   octave_value *clone (void) { return new octave_base_value (*this); }
  66.  
  67.   type_conv_fcn numeric_conversion_function (void) const
  68.     { return (type_conv_fcn) 0; }
  69.  
  70.   octave_value *try_narrowing_conversion (void)
  71.     { return (octave_value *) 0; }
  72.  
  73.   octave_value index (const octave_value_list& idx) const;
  74.  
  75.   idx_vector index_vector (void) const;
  76.  
  77.   octave_value struct_elt_val (const string& nm, bool silent) const;
  78.  
  79.   octave_value& struct_elt_ref (const string& nm);
  80.  
  81.   int rows (void) const { return -1; }
  82.  
  83.   int columns (void) const { return -1; }
  84.  
  85.   bool is_defined (void) const { return false; }
  86.  
  87.   bool is_real_scalar (void) const { return false; }
  88.  
  89.   bool is_real_matrix (void) const { return false; }
  90.  
  91.   bool is_complex_scalar (void) const { return false; }
  92.  
  93.   bool is_complex_matrix (void) const { return false; }
  94.  
  95.   bool is_char_matrix (void) const { return false; }
  96.  
  97.   bool is_string (void) const { return false; }
  98.  
  99.   bool is_range (void) const { return false; }
  100.  
  101.   bool is_map (void) const { return false; }
  102.  
  103.   bool is_magic_colon (void) const { return false; }
  104.  
  105.   bool is_all_va_args (void) const { return false; }
  106.  
  107.   octave_value all (void) const { return 0.0; }
  108.  
  109.   octave_value any (void) const { return 0.0; }
  110.  
  111.   bool is_real_type (void) const { return false; }
  112.  
  113.   bool is_complex_type (void) const { return false; }
  114.  
  115.   // Would be nice to get rid of the next four functions:
  116.  
  117.   bool is_scalar_type (void) const { return false; }
  118.  
  119.   bool is_matrix_type (void) const { return false; }
  120.  
  121.   bool is_numeric_type (void) const { return false; }
  122.  
  123.   bool valid_as_scalar_index (void) const { return false; }
  124.  
  125.   bool valid_as_zero_index (void) const { return false; }
  126.  
  127.   bool is_true (void) const { return false; }
  128.  
  129.   bool is_empty (void) const
  130.     { return (rows () == 0 || columns () == 0); }
  131.  
  132.   bool is_zero_by_zero (void) const
  133.     { return (rows () == 0 && columns () == 0); }
  134.  
  135.   double double_value (bool) const;
  136.  
  137.   Matrix matrix_value (bool frc_str_conv = false) const;
  138.  
  139.   Complex complex_value (bool frc_str_conv = false) const;
  140.  
  141.   ComplexMatrix complex_matrix_value (bool frc_str_conv = false) const;
  142.  
  143.   charMatrix char_matrix_value (bool frc_str_conv = false) const;
  144.  
  145.   string_vector all_strings (void) const;
  146.  
  147.   string string_value (void) const;
  148.  
  149.   Range range_value (void) const;
  150.  
  151.   Octave_map map_value (void) const;
  152.  
  153.   octave_value not (void) const;
  154.  
  155.   octave_value uminus (void) const;
  156.  
  157.   octave_value transpose (void) const;
  158.  
  159.   octave_value hermitian (void) const;
  160.  
  161.   void increment (void);
  162.  
  163.   void decrement (void);
  164.  
  165.   octave_value convert_to_str (void) const;
  166.  
  167.   void convert_to_row_or_column_vector (void);
  168.  
  169.   void print (ostream& os, bool pr_as_read_syntax = false);
  170.  
  171.   int type_id (void) const { return t_id; }
  172.  
  173.   string type_name (void) const { return t_name; }
  174.  
  175.   static int static_type_id (void) { return t_id; }
  176.  
  177.   static void register_type (void)
  178.     { t_id = octave_value_typeinfo::register_type (t_name); }
  179.  
  180. private:
  181.  
  182.   // Type id of base value objects, set by register_type().
  183.   static int t_id;
  184.  
  185.   // Type name of base value objects, defined in ov-base.cc.
  186.   static const string t_name;
  187. };
  188.  
  189. #endif
  190.  
  191. extern void install_base_type_conversions (void);
  192.  
  193. /*
  194. ;;; Local Variables: ***
  195. ;;; mode: C++ ***
  196. ;;; End: ***
  197. */
  198.